package com.newcoder.huawei;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class JZ6 {

    public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {

        ArrayList<Integer> resultList = new ArrayList<Integer>();
        resultList.add(listNode.getVal());
        while (listNode.next!=null){
            listNode = listNode.next;
            resultList.add(listNode.getVal());
        }
        Collections.reverse(resultList);
        return resultList;

    }

}


